<?php
namespace app\common\validate;

use think\Validate;

class User extends Validate
{
    protected $rule =   [
        'mobile'  => 'require|mobile',
        'email' => 'require|email',
        'invite_code' =>'require',
        'password'=>'require|min:6',
        'isCheckEmail'=>'require',
        'code'=>'require|min:4',
        'token'=>'require|min:30',
        'nickname'=>'require',
        'wx_nickname'=>'require',
        'sex'=>'number|between:1,3',
        'birthday'   => 'require',

        'introduction'   => 'require',
        'introduction_url'   => 'require',
        'er_code'   => 'require',
        'head_url'   => 'require',
        'desc'   => 'require',

    ];

    protected $message  =   [
        'mobile.require'     => '手机号必须填写',
        'mobile'        => '手机号格式错误',
        'email.require' => '邮箱必须填写',
        'email'        => '邮箱格式错误',
        'invite_code.require' => '邀请码必须填写',
        'password.require' => '密码不能为空！',
        'password' => '密码格式错误！',
        'isCheckEmail.require' => 'isCheckEmail参数不能为空！',
        'code.require' => '验证码不能为空！',
        'code' => '验证码格式错误！',
        'token.require' => 'token不能为空！',
        'token' => 'token格式错误！',
        'sex.number'   => '性别必须是数字',
        'sex.between'  => '性别只能在1-3之间',
        'nickname.require'     => '昵称必须填写',
        'birthday.require'     => '生日必须填写',

        'introduction.require'     => '个人介绍必须填写',
        'introduction_url.require'     => '个人主页地址必须填写',
        'er_code.require'     => '二维码地址必须填写',
        'head_url.require'     => '头像地址必须填写',
        'desc.require'     => '注释必须填写',
    ];

    /**
     * @var array 验证的场景
     */
    protected $scene = [
        'emailRegister'  =>  ['mobile','email','invite_code','password'],
        'resetPassword'  =>  ['email','password','code'],
        'sendEmailCode'  =>  ['email'],
        'checkEmailCode'  =>  ['email','code'],
        'checkMailExist'  =>  ['email'],
        'mailLogin'  =>  ['email','password'],
        'checkToken'  =>  ['token'],
        'update_nickname'  =>  ['nickname'],
        'update_wx_nickname'  =>  ['wx_nickname'],
        'update_sex'  =>  ['sex'],
        'update_birthday'  =>  ['birthday'],
        'update_introduction'  =>  ['introduction'],
        'update_mobile'  =>  ['mobile'],
        'update_introduction_url'  =>  ['introduction_url'],
        'update_er_code'  =>  ['er_code'],
        'update_head_url'  =>  ['head_url'],
        'update_desc'  =>  ['desc'],
        'update_invite_code'  =>  ['invite_code'],
    ];

//    protected $canDealArray = array('nickname','sex','birthday','introduction','mobile','introduction_url','er_code','head_url','desc','invite_code');
}
